FROM node:12

WORKDIR /usr/src/app

COPY package*.json ./

# 安装 GraphicsMagick
COPY ./GraphicsMagick-1.3.36.tar.gz /usr/local/share/GraphicsMagick-1.3.36.tar.gz
RUN cd /usr/local/share/ && tar -zxvf GraphicsMagick-1.3.36.tar.gz && cd ./GraphicsMagick-1.3.36 && ./configure --prefix=/usr/local/GraphicsMagick --enable-shared --without-prel --enable-shared --disable-openmp && make && make install
# 安装 gm 模块
RUN npm install gm -g --registry=https://registry.npm.taobao.org

COPY ./phantomjs-1.9.8-linux-x86_64.tar.bz2 /usr/local/share/phantomjs-1.9.8-linux-x86_64.tar.bz2
RUN cd /usr/local/share/ && tar -xvf phantomjs-1.9.8-linux-x86_64.tar.bz2

ENV PHANTOMJS_HOME /usr/local/share/phantomjs-1.9.8-linux-x86_64
ENV PATH $PATH:$PHANTOMJS_HOME
ENV LANG C.UTF-8

# 安装cnpm 解决 install 慢的问题
#RUN npm install -g cnpm --registry=https://registry.npm.taobao.org
#RUN cnpm install
RUN npm install --registry=https://registry.npm.taobao.org

COPY . .

EXPOSE 3000

RUN npm install pm2 -g --registry=https://registry.npm.taobao.org && pm2 install pm2-logrotate

CMD [ "pm2", "start", "./bin/www", "--no-daemon", "--name", "gs" ]
